<include file="public@header" />
<style>
	html {background-color: #ffffff;}
	#container {width:100%; height: 300px; }
</style>

<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
</head>
<body>
	<div class="layui-fluid">
		<form method="post" class="layui-form js-ajax-form" style="margin-top:20px ;" action="{:url('merchant.store/addPost')}">
			<div class="layui-col-md12">
				<div class="layui-card">
					<div class="layui-tab layui-tab-brief">
						<ul class="layui-tab-title">
							<li ><a href="javascript:history.go(-1)">列表</a></li>
							<li class="layui-this"><a >{:lang('ADD')}</a></li>
						</ul>
					</div>

					<div class="layui-card-body">
						<div class="layui-form-item">
							<label class="layui-form-label"><span class="form-required">*</span>店铺类型</label>
							<div class="layui-input-block">
								<select class="layui-input" name="type_id" id="store_type_id" lay-filter="type_id">
									<volist name="typelist" id="v">
										<option value="{$v['id']}">{$v['html']}{$v['name']}</option>
									</volist>
								</select>
							</div>
						</div>

		

						<div class="layui-form-item">
							<label class="layui-form-label"><span class="form-required">*</span>店铺名称</label>
							<div class="layui-input-block">
								<input type="text" class="layui-input" name="name" required>
							</div>
						</div>


						<div class="layui-form-item">
							<label class="layui-form-label"><span class="form-required">*</span>店铺封面</label>
							<div class="layui-input-block">
								<input type="hidden" name="thumb" id="thumb" value="">
								<a href="javascript:uploadOneImage('图片上传','#thumb');">
									<img src="__TMPL__/public/assets/images/default-thumbnail.png" id="thumb-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
								</a>
								<div class="layui-col-md12" style="margin-top: 10px">
									<input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
										   onclick="$('#thumb-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#thumb').val('');return false;"
										   value="取消图片">
								</div>
							</div>
						</div>

						<div class="layui-form-item" style="display: none;">
							<label class="layui-form-label"><span class="form-required">*</span>店铺背景</label>
							<div class="layui-input-block">
								<input type="hidden" name="background" id="background" value="">
								<a href="javascript:uploadOneImage('图片上传','#background');">
									<img src="__TMPL__/public/assets/images/default-thumbnail.png" id="background-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
								</a>
								<div class="layui-col-md12" style="margin-top: 10px">
									<input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
										   onclick="$('#background-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#background').val('');return false;"
										   value="取消图片">
								</div>
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label"><span class="form-required">*</span>店铺地址</label>
							<div class="layui-input-block">
								<input type="text" class="layui-input" name="address" id="address" required>
								<input type="hidden" class="layui-input" name="lng" id="lng" required>
								<input type="hidden" class="layui-input" name="lat" id="lat" required>
								<div id="container"></div>

							</div>
						</div>


						<if condition="in_array($top_type_id,[1,5,6,7,8])">
						<div class="layui-form-item">
							<label class="layui-form-label"><span class="form-required">*</span>法人姓名</label>
							<div class="layui-input-block">
								<input type="text" class="layui-input" name="person_name" required>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label"><span class="form-required">*</span>身份证号</label>
							<div class="layui-input-block">
								<input type="text" class="layui-input" name="id_card" required>
							</div>
						</div>


						<div class="layui-form-item">
							<label class="layui-form-label"><span class="form-required">*</span>身份证照片(正面)</label>
							<div class="layui-input-block">
								<input type="hidden" name="id_card_image_0" id="id_card_image_0" value="">
								<a href="javascript:uploadOneImage('图片上传','#id_card_image_0');">
									<img src="__TMPL__/public/assets/images/default-thumbnail.png" id="id_card_image_0-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
								</a>
								<div class="layui-col-md12" style="margin-top: 10px">
									<input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
										   onclick="$('#id_card_image_0-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#id_card_image_0').val('');return false;"
										   value="取消图片">
								</div>
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label"><span class="form-required">*</span>身份证照片(反面)</label>
							<div class="layui-input-block">
								<input type="hidden" name="id_card_image_1" id="id_card_image_1" value="">
								<a href="javascript:uploadOneImage('图片上传','#id_card_image_1');">
									<img src="__TMPL__/public/assets/images/default-thumbnail.png" id="id_card_image_1-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
								</a>
								<div class="layui-col-md12" style="margin-top: 10px">
									<input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
										   onclick="$('#id_card_image_1-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#id_card_image_1').val('');return false;"
										   value="取消图片">
								</div>
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label"><span class="form-required">*</span>工商注册号</label>
							<div class="layui-input-block">
								<input type="text" class="layui-input" name="registr_id" required>
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label"><span class="form-required">*</span>营业执照(正面)</label>
							<div class="layui-input-block">
								<input type="hidden" name="business_image_0" id="business_image_0" value="">
								<a href="javascript:uploadOneImage('图片上传','#business_image_0');">
									<img src="__TMPL__/public/assets/images/default-thumbnail.png" id="business_image_0-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
								</a>
								<div class="layui-col-md12" style="margin-top: 10px">
									<input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
										   onclick="$('#business_image_0-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#business_image_0').val('');return false;"
										   value="取消图片">
								</div>
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label"><span class="form-required">*</span>许可证编号</label>
							<div class="layui-input-block">
								<input type="text" class="layui-input" name="license_number" required>
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label"><span class="form-required">*</span>许可证照</label>
							<div class="layui-input-block">
								<input type="hidden" name="license_image_0" id="license_image_0" value="">
								<a href="javascript:uploadOneImage('图片上传','#license_image_0');">
									<img src="__TMPL__/public/assets/images/default-thumbnail.png" id="license_image_0-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
								</a>
								<div class="layui-col-md12" style="margin-top: 10px">
									<input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
										   onclick="$('#license_image_0-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#license_image_0').val('');return false;"
										   value="取消图片">
								</div>
							</div>
						</div>
						</if>

						<if condition="in_array($top_type_id,[3])">
						<div class="layui-form-item layui-form-text">
							<label class="layui-form-label">关于</label>
							<div class="layui-input-block">
								<textarea class="layui-textarea" name="about" ></textarea>
							</div>
						</div>
						</if>

						<if condition="in_array($top_type_id,[4])">
							<div class="layui-form-item">
								<label class="layui-form-label">人均消费(找店)</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" name="per_capita" value="0">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">总评分(找店)</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" name="stars" value="0">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">口味评分(找店)</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" name="taste_score" value="0">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">环境评分(找店)</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" name="environment_score" value="0">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">服务评分(找店)</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" name="service_score" value="0">
								</div>
							</div>
						</if>


						<div class="layui-form-item">
							<div class="layui-input-block">
								<button type="submit" class="layui-btn js-ajax-submit">{:lang('ADD')}</button>
								<a class="layui-btn layui-btn-primary btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
							</div>
						</div>
					</div>
				</div>
			</div>
		</form>
	</div>
	<include file="public@script"/>
	<script type="text/javascript">
		window._AMapSecurityConfig = {
			securityJsCode:'{$gaode_secret}',
		}
	</script>
	<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key={$gaode_key}"></script>
	<script type="text/javascript">
		//地图加载
		var map = new AMap.Map("container", {
			resizeEnable: true
		});

		map.plugin(['AMap.Autocomplete','AMap.PlaceSearch'], function(){
			// 实例化Autocomplete
			var autoOptions = {
				// input 为绑定输入提示功能的input的DOM ID
				input: 'address'
			}
			var auto= new AMap.Autocomplete(autoOptions);

			// 无需再手动执行search方法，autoComplete会根据传入input对应的DOM动态触发search
			var placeSearch = new AMap.PlaceSearch({
				map: map
			});
			//构造地点查询类
			auto.on("select", select);//注册监听，当选中某条记录时会触发
			function select(e) {

				placeSearch.search(e.poi.name, function (status, result) {

					//关键字查询
					placeSearch.search(e.poi.name);
					placeSearch.on('markerClick',function(e){
						$('#address').val(e.data.address+' '+e.data.name);
						$('#lng').val(e.event.lnglat.lng);
						$('#lat').val(e.event.lnglat.lat);
					})
				});

			}

		})

	</script>
</body>
</html>